package com.lefevre.cms.bean.membershipCard;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 会员卡规格
 *
 * @author Lefevre
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("specification")
@Entity
@Table(indexes = {@Index(name = "specification_1_idx", columnList = "membershipCardId,sort")})
public class Specification implements Serializable {
    private static final long serialVersionUID = 7157973122318114404L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.INPUT)
    private Long id;

    /**
     * 规格名称
     **/
    @Column(length = 100)
    @TableField("specificationName")
    private String specificationName;

    /**
     * 会员卡Id
     **/
    @TableField("membershipCardId")
    private Long membershipCardId;

    /**
     * 可用库存量
     **/
    @TableField("stock")
    private Long stock = 0L;

    /**
     * 占用库存量(已出售库存量)
     **/
    @TableField("stockOccupy")
    private Long stockOccupy = 0L;

    /**
     * 增/减 库存状态   0:不变  1:增加   2:减少
     **/
    @Transient
    @TableField(exist = false)
    private Integer stockStatus = 0;

    /**
     * 更改库存
     **/
    @Transient
    @TableField(exist = false)
    private Long changeStock;

    /**
     * 支付积分
     **/
    @TableField("point")
    private Long point;

    /**
     * 市场价 精度为12位，小数点位数为2位
     **/
    @Column(precision = 12, scale = 2)
    @TableField(value = "marketPrice", numericScale = "2")
    private BigDecimal marketPrice;

    /**
     * 销售价 精度为12位，小数点位数为2位
     **/
    @TableField(value = "sellingPrice", numericScale = "2")
    @Column(precision = 12, scale = 2)
    private BigDecimal sellingPrice;

    /**
     * 有效期
     **/
    @TableField("duration")
    private Integer duration;

    /**
     * 时长单位 10.小时 20.日 30.月 40.年
     **/
    @TableField("`unit`")
    private Integer unit;

    /**
     * 排序
     **/
    @TableField("sort")
    private Integer sort = 0;

    /**
     * 是否启用  true:启用 false:禁用
     **/
    @TableField("enable")
    private boolean enable = true;

}
